package com.leoncom.sms_silencer.util;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SmsSQLiteHelper extends SQLiteOpenHelper {

	 public static final String TABLE_TASK = "tasks";
	 public static final String COLUMN_ID = "_id";
	 public static final String COLUMN_HOUR = "hour";
	 public static final String COLUMN_MIN = "min";
	 public static final String COLUMN_PERIOD = "period";
	 public static final String COLUMN_REPEATED = "repeated";

	 private static final String DATABASE_NAME = "commments.db";
	 private static final int DATABASE_VERSION = 3;
	 
	// Database creation sql statement
	  private static final String DATABASE_CREATE = "create table "
	      + TABLE_TASK + "(" + COLUMN_ID
	      + " integer primary key autoincrement, " + COLUMN_HOUR
	      + " integer not null, " + COLUMN_MIN 
	      + " integer not null, " + COLUMN_PERIOD 
	      + " integer not null, " + COLUMN_REPEATED 
	      + " varchar(64) not null);";  
	
	public SmsSQLiteHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_TASK);
	    onCreate(db);
	}

}
